import { createRouter, createWebHistory } from 'vue-router'
import layout from '@/views/layout/index.vue'
import brand from '@/views/category/categoryBrands.vue'
import campusOrShop from '@/views/category/categoryCampus.vue'
import home from '@/views/home/index.vue'
import login from '@/views/login/index.vue'
import details from '@/views/details/index.vue'
import list from '@/views/list/index.vue'
import member from '@/views/member/index.vue'
import order from '@/views/member/components/order.vue'
import user from '@/views/member/components/user.vue'
import mySell from '@/views/member/components/mySell.vue'
import pubnish from '@/views/member/components/publish.vue'
import browseVehicle from '@/views/vehicle/browseVehicle.vue'
import addVehicle from '@/views/vehicle/addVehicle.vue'
import orderPage from '@/views/order/index.vue'
import payPage from '@/views/order/payPage.vue'
import payResult from '@/views/order/payResult.vue'
import orderDetails from '@/views/order/orderDetails.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: layout,
      children: [
        {
          path: '',
          component: home
        },
        {
          path: 'brand/:id',
          component: brand
        },
        {
          path: 'campusOrShop/:type',
          component: campusOrShop
        },
        {
          path: 'details/:id',
          component: details
        },
        {
          path: 'list',
          component: list
        },
        {
          path: 'member',
          component: member,
          redirect: 'member/user',
          children: [
            {
              path: 'user',
              component: user
            },
            {
              path: 'order',
              component: order
            },
            {
              path: 'publish',
              component: pubnish
            },
            {
              path: 'mySells',
              component: mySell
            }
          ]
        },
        {
          path: 'vehicle/add/:id?',
          component: addVehicle
        },
        {
          path: 'vehicle/browse/:id',
          component: browseVehicle
        },
        {
          path: 'order/:id',
          component: orderPage
        },
        {
          path: 'order/payPage/:id',
          component: payPage
        },
        {
          path: 'order/payResult',
          component: payResult
        },
        {
          path: 'order/details/:id',
          component: orderDetails
        }
      ]
    },
    {
      path: '/login',
      component: login
    }
  ],
  scrollBehavior() {
    return {
      top: 0
    }
  }
})

export default router
